package com.yanqu.road.server.cmd.inn;

import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.inn.InnProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.inn.InnModule;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_INN_DISHES_UPGRADE_ONE_KEY, desc = "菜品技能升级(一键升级)")
public class InnDishesUpgradeOneKeyCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if (!SystemOpenMgr.systemOpen(player, eSystemId.Inn.getValue())) {
            ret = GameErrorCode.E_SYSTEM_NO_OPEN;
            return;
        }

        InnModule module = player.getModule(InnModule.class);
        ret = module.dishesUpgradeOneKey();
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0) {
            InnProto.InnDishesUpgradeOneKeyRspMsg.Builder respMsg = InnProto.InnDishesUpgradeOneKeyRspMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_INN_DISHES_UPGRADE_ONE_KEY, respMsg);
        }
    }
}
